package com.xh.blog.user.web.controller;
import com.xh.blog.common.wrapper.ResponseWrapper;
import com.xh.blog.user.api.UserInfoApi;
import com.xh.blog.user.model.dto.UserInfoDto;
import com.xh.blog.user.service.UserService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by xieha on 2019-11-23.
 */

@ApiOperation(value = "用户接口")
@RestController
@RequestMapping("/api/open/user")
public class UserController implements UserInfoApi {
    @Autowired
    UserService userService;
    @ApiOperation(value = "增加用户接口")
    @PostMapping("/add")
    public ResponseWrapper<Long> insertUserInfo(@RequestBody UserInfoDto userInfo){
       return ResponseWrapper.getInstance().success(userService.insertUser(userInfo));
    }

    @ApiOperation(value = "查询用户")
    @GetMapping("/{userId}")
    public ResponseWrapper<UserInfoDto> getUserInfo(@ApiParam(value = "用户id") @PathVariable(value = "userId") Long userId){
        return ResponseWrapper.getInstance().success(userService.getUser(userId));
    }


}
